package com.example.fluttervideodemo

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.fluttervideodemo.databinding.ActivityMainBinding
import io.flutter.embedding.android.FlutterFragment

class MainActivity : AppCompatActivity() {


    private lateinit var binding: ActivityMainBinding

    private val friendFragment by lazy {
        FlutterFragment.withNewEngine().initialRoute("/home/friend").build<FlutterFragment>()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        ViewCompat.setOnApplyWindowInsetsListener(binding.main) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        binding.tv.setOnClickListener {
            supportFragmentManager.beginTransaction().add(R.id.fragment_container,friendFragment).commit()
        }

    }
}